home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Games / net3d-0.08 / net3d.h < prev    next >
C/C++ Source or Header  |  1995-06-22  |  4KB  |  173 lines

  1. /* net3d.h
  2.  *
  3.  * Include files, common definitions and global variables
  4.  */
  5. #ifndef net3d_h
  6. #define net3d_h
  7.  
  8. /* current version number. All clients must be using the same version
  9.  * to stay synchronised. */
  10. #define NET3D_VERSION "0.08"
  11. #define VERSION_ERROR "net3d version mismatch"
  12.  
  13. /* bug fix under linux */
  14. #ifdef linux
  15. #define float double
  16. #endif
  17.  
  18. /* commonly used types */
  19. typedef signed char byte;
  20. typedef unsigned char ubyte;
  21. typedef enum{false=0, true=1} bool;
  22.  
  23. struct cache {
  24.     double val;            /* input value */
  25.     double res;            /* corresponding output */
  26.     long lastused;            /* time of last call */
  27.     bool inuse;            /* is this cache line in use? */
  28.     };
  29. /* a cache line, usually used in an array to form a cache */
  30.  
  31. /* Include files */
  32. #define NeedFunctionPrototypes 1    /* why is this needed ?!? */
  33. #include <X11/Xlib.h>
  34. #include <X11/Xutil.h>
  35. #include <X11/keysym.h>
  36.  
  37. #include <stdio.h>
  38. #include <stdlib.h>
  39. #include <string.h>
  40. #include <math.h>
  41. #include <time.h>
  42. #include <signal.h>
  43. #include <limits.h>
  44. #include <float.h>
  45. #include <fcntl.h>
  46. #include <unistd.h>
  47. #include <sys/time.h>
  48. #include <sys/stat.h>
  49. #include <sys/types.h>
  50. #include <sys/socket.h>
  51. #include <sys/wait.h>
  52. #if !defined(NO_SELECT_H) && !defined(__FreeBSD__)
  53. #include <sys/select.h>
  54. #endif
  55. #include "config.h"
  56. #include "3d.h"
  57. #include "brain.h"
  58. #include "protos.h"
  59. #include "netprotos.h"
  60.  
  61. /* defines used in creating 3-d view */
  62. #define WINDOW_W 400
  63. #define WINDOW_H 400
  64. #define SCALE 160
  65. #define VIEW_RANGE 2000.0
  66. #define EYE_DISTANCE 3.0
  67. #define RADAR_RANGE 2000
  68. #define STARSCALE 500
  69.  
  70. /* defines limiting max size of object, vehicles & faces */
  71. #define MAX_POINTS_PER_FACE 20
  72. #define MAX_POINTS_PER_OBJECT 100
  73. #define MAX_FACES_PER_OBJECT 100
  74. #define MAX_PARTS_PER_VEHICLE 110
  75. #define MAX_OSCLI_PER_OBJECT 30
  76.  
  77. /* defines used in networking */
  78. #define MAX_PLAYERS 20
  79.  
  80. /* assorted definitions */
  81. #ifndef PI        /* already defined under Linux */
  82. #define PI 3.1415927
  83. #endif
  84. #define DEATH_MSG "Your vehicle has been destroyed"
  85. #define WINNER_MSG "All other players have been destroyed. You win!"
  86. #define FIREBALLS 30
  87. #define PLAYERTYPE t_fish
  88. #define KEYFILE ".net3drc"
  89.  
  90. /* definitions for growning trees */
  91. #define GROWTHRATE 1.01
  92.  
  93. /* definitions for movement */
  94. #define DELTA_ANGLE dtor(0.2)
  95. #define DELTA_ALT   0.5
  96.  
  97. #define DELTA_ANGLE_VEL dtor(5.0)
  98. #define DELTA_VELOCITY 2.0
  99. #define DELTA_CLIMB 5.0
  100. #define DELTA_TURRET_ANG dtor(5.0)
  101. #define MAX_VELOCITY 150.0
  102. #define MAX_ANGLE_VEL PI/4.0
  103. #define MAX_ALTITUDE 2000.0
  104. #define MAX_TURRET_ANG dtor(45.0)
  105. #define FRICTION 100.0            /* rate at which rotating things slow */
  106.  
  107. /* definitions for brains */
  108. #define MAX_STATES_PER_VEHICLE 50
  109. #define MAX_LINKS_PER_STATE 20
  110.  
  111. /* rate at which things fall in the game */
  112. #define GRAVITY 40
  113.  
  114. /* simple defined functions */
  115. #define dtor(x)        ((x)/(180.0/PI))
  116. #define rtod(x)        ((x)*(180.0/PI))
  117. #define max(x,y)    ((x) > (y) ? (x) : (y))
  118. #define min(x,y)    ((x) < (y) ? (x) : (y))
  119. #define chksum(p)    ((p).x + (p).y + (p).z)
  120.  
  121. /* external global variables and functions */
  122. extern Display *display;
  123. extern GC view_gc;
  124. extern Window view_win;
  125. extern Pixmap view_pm;
  126. extern Colormap view_cm;
  127. extern bool wireframe;
  128. extern double gtm;
  129. extern int vidcount;
  130. extern int stillalive;
  131. extern bool singlep;
  132. extern int window_w, window_h;
  133. extern double vmax[];
  134. extern char *extras[];
  135. extern char fakepipe[];
  136. extern bool buildicons;
  137. extern int linenum;
  138. extern struct vehicle *evhead;
  139. extern struct object *eohead;
  140. extern char *pnames[];
  141. extern vehicle_type playertype;
  142. extern int ctrlc;
  143. extern int sock;
  144.  
  145. /* global variables containing information about map cacheing 
  146.  * efficiency. */
  147. extern int mappointsdone;
  148. extern int mapcachehits;
  149.  
  150. /* variables containing into about sin caching */
  151. extern int sincalls;
  152. extern int sincachehits;
  153.  
  154. extern double (sinhalf)(double);
  155. extern double (sinsq)(double);
  156.  
  157. /* the matrix multiply function, defined inline if using gcc */
  158. #if defined(__GNUC__) && USEINLINES == 1
  159. static inline void mmult(struct point *p, float m[3][3], struct point *r)
  160. {
  161. r->x=p->x*m[0][0] + p->y*m[0][1] + p->z*m[0][2];
  162. r->y=p->x*m[1][0] + p->y*m[1][1] + p->z*m[1][2];
  163. r->z=p->x*m[2][0] + p->y*m[2][1] + p->z*m[2][2];
  164. }
  165.  
  166. static inline float cmult(struct point *p, float l[3])
  167. {
  168. return p->x*l[0] + p->y*l[1] + p->z*l[2];
  169. }
  170. #endif
  171.  
  172. #endif
  173.